﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PhamMemQuanLyHocSinh
{
    public partial class frmMain : Form
    {
        public frmMain()
        {
            InitializeComponent();
        }
        private bool KiemTraTonTai(string name)
        {
            bool KT = false;
            foreach (Form frm in this.MdiChildren)
            {
                if (frm.Name == name)
                {
                    KT = true;
                    break;
                }
            }
            return KT; 
        }
        private void HienThiOnTop(string name)
        {
            foreach (Form frm in this.MdiChildren)
            {
                if (frm.Name == name)
                {
                    frm.Activate();
                    break;
                }
            }
        }       

        private void btnDangNhap_Click(object sender, EventArgs e)
        {

            if (!KiemTraTonTai("frmDangNhap"))
            {
                frmDangNhap fDN = new frmDangNhap();
                fDN.MdiParent = this;
                fDN.Show();
            }
            else
                HienThiOnTop("frmDangNhap");
        }
        private void btnDoiMatKhau_Click(object sender, EventArgs e)
        {
            if (!KiemTraTonTai("frmDoiMatKhau"))
            {
                frmDoiMatKhau fDMK = new frmDoiMatKhau();
                fDMK.MdiParent = this;
                fDMK.Show();
            }
            else
                HienThiOnTop("frmDoiMatKhau");
        }

        private void btnThemKhoiLop_Click(object sender, EventArgs e)
        {
            if (!KiemTraTonTai("frmQLKhoiLop"))
            {
                frmQLKhoiLop fQLKL = new frmQLKhoiLop();
                fQLKL.MdiParent = this;
                fQLKL.Show();
            }
            else
                HienThiOnTop("frmQLKhoiLop");
        }

        private void btnPCGD_Click(object sender, EventArgs e)
        {
            if (!KiemTraTonTai("frmPCGD"))
            {
                frmPCGD fPCGD = new frmPCGD();
                fPCGD.MdiParent = this;
                fPCGD.Show();
            }
            else
                HienThiOnTop("frmPCGD");
        }

        private void btnQLNV_Click(object sender, EventArgs e)
        {
            //if (!KiemTraTonTai("frmQLNV"))
            //{
            //    frmQLNV fQLNV = new frmQLNV();
            //    fQLNV.MdiParent = this;
            //    fQLNV.Show();
            //}
            //else
            //    HienThiOnTop("frmQLNV");
        }

        private void btnQLHS_Click(object sender, EventArgs e)
        {
            if (!KiemTraTonTai("frmQLHS"))
            {
                frmQLSV fQLHS = new frmQLSV();
                fQLHS.MdiParent = this;
                fQLHS.Show();
            }
            else
                HienThiOnTop("frmQLHS");

        }

       


        
        
    }
}
